

#ifndef   _UCRX_EVENT_H__
#define   _UCRX_EVENT_H__

#include "zacarray.h"
#include "zrxobject.h"
#include "zAdAChar.h"
#include "zdbid.h"
#pragma pack (push, 8)

#define UCRX_EVENT_OBJ UCRX_T("UcRxEvent")

class UcDbDatabase;
class UcGeMatrix3d;
class UcDbIdMapping;
class UcGePoint3d;

enum UcXrefSubCommand {
    kAttach = 0,
    kBind = 1,
    kDetach = 2,
    kOverlay = 3,
    kPath = 4,
    kReload = 5,
    kResolve = 6,
    kUnload = 7,
    kXBind = 8
};

class UcRxEventReactor: public UcRxObject 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcRxEventReactor);

    virtual void dwgFileOpened(UcDbDatabase*, ZTCHAR * fileName);
    virtual void initialDwgFileOpenComplete(UcDbDatabase*);
    virtual void databaseConstructed(UcDbDatabase*);
    virtual void databaseToBeDestroyed(UcDbDatabase*);

    virtual void beginSave    (UcDbDatabase*, const ZTCHAR * pIntendedName);
    virtual void saveComplete (UcDbDatabase*, const ZTCHAR * pActualName);
    virtual void abortSave    (UcDbDatabase*);

    virtual void beginDxfIn      (UcDbDatabase*);
    virtual void abortDxfIn      (UcDbDatabase*);
    virtual void dxfInComplete   (UcDbDatabase*);
    
    virtual void beginDxfOut     (UcDbDatabase*);
    virtual void abortDxfOut     (UcDbDatabase*);
    virtual void dxfOutComplete  (UcDbDatabase*);

    virtual void beginInsert(UcDbDatabase* pTo, const ZTCHAR * pBlockName,
                             UcDbDatabase* pFrom);
    virtual void beginInsert(UcDbDatabase* pTo, const UcGeMatrix3d& xform,
                             UcDbDatabase* pFrom);
    virtual void otherInsert(UcDbDatabase* pTo, UcDbIdMapping& idMap,
                             UcDbDatabase* pFrom);
    virtual void abortInsert(UcDbDatabase* pTo);
    virtual void endInsert  (UcDbDatabase* pTo);

    virtual void wblockNotice(UcDbDatabase* pDb);
    virtual void beginWblock(UcDbDatabase* pTo, UcDbDatabase* pFrom,
                             const UcGePoint3d*& insertionPoint);
    virtual void beginWblock(UcDbDatabase* pTo, UcDbDatabase* pFrom,
                             UcDbObjectId blockId);
    virtual void beginWblock(UcDbDatabase* pTo, UcDbDatabase* pFrom); 
    virtual void otherWblock(UcDbDatabase* pTo, UcDbIdMapping&,
                             UcDbDatabase* pFrom);
    virtual void abortWblock(UcDbDatabase* pTo);
    virtual void endWblock  (UcDbDatabase* pTo);
    virtual void beginWblockObjects(UcDbDatabase*, UcDbIdMapping&);

    virtual void beginDeepClone       (UcDbDatabase* pTo, UcDbIdMapping&);
    virtual void beginDeepCloneXlation(UcDbIdMapping&, Ucad::ErrorStatus*);
    virtual void abortDeepClone       (UcDbIdMapping&);
    virtual void endDeepClone         (UcDbIdMapping&);

    virtual void partialOpenNotice  (UcDbDatabase* pDb);
    virtual void beginAttach (UcDbDatabase* pTo, const ZTCHAR *,
                              UcDbDatabase* pFrom);
    virtual void otherAttach (UcDbDatabase* pTo, UcDbDatabase* pFrom);
    virtual void abortAttach (UcDbDatabase* pFrom);
    virtual void endAttach   (UcDbDatabase* pTo);
    virtual void redirected  (UcDbObjectId  newId, UcDbObjectId oldId);
    virtual void comandeered (UcDbDatabase* pTo, UcDbObjectId id,
                              UcDbDatabase* pFrom);
    virtual void beginRestore(UcDbDatabase* pTo, const ZTCHAR *,
                              UcDbDatabase* pFrom);
    virtual void abortRestore(UcDbDatabase* pTo);
    virtual void endRestore  (UcDbDatabase* pTo);

	virtual void xrefSubcommandBindItem   (UcDbDatabase* pHost, int activity, UcDbObjectId blockId);
	virtual void xrefSubcommandAttachItem (UcDbDatabase* pHost, int activity, const ZTCHAR* pPath);
	virtual void xrefSubcommandOverlayItem(UcDbDatabase* pHost, int activity, const ZTCHAR* pPath);
	virtual void xrefSubcommandDetachItem (UcDbDatabase* pHost, int activity, UcDbObjectId blockId);
	virtual void xrefSubcommandPathItem   (int activity, UcDbObjectId blockId, const ZTCHAR* pNewPath);
	virtual void xrefSubcommandReloadItem (UcDbDatabase* pHost, int activity, UcDbObjectId blockId);	
	virtual void xrefSubcommandUnloadItem (UcDbDatabase* pHost, int activity, UcDbObjectId blockId);

    virtual void xrefSubCommandStart(UcDbDatabase* pHostDb,
            UcXrefSubCommand op, const UcArray<UcDbObjectId>& ids,
            const ZTCHAR* const* btrNames,
            const ZTCHAR* const* paths, bool& vetoOp);

    virtual void xrefSubCommandAborted(UcDbDatabase* pHostDb,
            UcXrefSubCommand op, const UcArray<UcDbObjectId>& ids,
            const ZTCHAR* const* btrNames,
            const ZTCHAR* const* paths);

	virtual void xrefSubCommandEnd(UcDbDatabase* pHostDb,
			UcXrefSubCommand op, const UcArray<UcDbObjectId>& ids,
			const ZTCHAR* const* btrNames, 
			const ZTCHAR* const* paths);
    virtual void preXrefLockFile(UcDbDatabase* pDb,
            UcDbObjectId btrId);
};

#define ucrxEvent UcRxEvent::cast(ucrxSysRegistry()->at(UCRX_EVENT_OBJ))

class UcRxEvent: public UcRxObject 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcRxEvent);
    virtual void addReactor   (UcRxEventReactor * newObj) = 0;
    virtual void removeReactor(UcRxEventReactor * delObj) = 0;
};

#pragma pack (pop)
#endif
